package cn.e_eap.esite.action;

import cn.e_eap.esite.web.SystemContext;
import cn.e_eap.esite.web.form.PagerForm;

import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionSupport;

public class BaseAction extends ActionSupport implements PagerForm {
	
	private String method="add";
	
	private String action;
	
	private int numPerPage = 10;
	
	private int pageNum = 1;
	
	private long totalCount;
	
	public String add() {
		if("update".equalsIgnoreCase(method)) {
			return doUpdate();
		} else {
			return doAdd();
		}		
	}
	
	@Override
	public String input() {
		
		return "input";
	}

	public String delete() {
		return SystemContext.Action.DEL_SUCCESS;
	}

	protected String doAdd() {
		
		return SystemContext.Action.ADD_SUCCESS;
	}
	
	public String update() {
		
		return doUpdate();
	}
	
	protected String doUpdate() {		
		return SystemContext.Action.UPDATE_SUCCESS;
	}
	
	@Override
	public String execute() throws RuntimeException{
		
		
		
		return Action.SUCCESS;
	}
	
	public String getMethod() {
		return method;
	}

	@Override
	public int getNumPerPage() {
		return numPerPage;
	}

	@Override
	public int getPageNum() {
		return pageNum;
	}

	public long getTotalCount() {
		return totalCount;
	}

	public void setCurrentPage(int currentPage) {
		this.pageNum = currentPage;
	}

	public void setMethod(String method) {
		this.method = method;
	}

	public void setNumPerPage(int numPerPage) {
		this.numPerPage = numPerPage;
	}

	@Override
	public void setTotalCount(long totalCount) {
		this.totalCount = totalCount;
	}

	public String getAction() {
		return action;
	}

	public void setAction(String action) {
		this.action = action;
	}
	
	
}
